package com.yuchen.ishop.goods;

import com.alibaba.dubbo.rpc.protocol.rest.support.ContentType;
import com.yuchen.core.MyPager;
import com.yuchen.core.jdbc.BaseDao;
import com.yuchen.ishop.MyPagerUtils;
import com.yuchen.ishop.entity.GoodsXiaoqu;
import com.yuchen.jaxrs.ResponseUtils;
import com.yuchen.jaxrs.Responses;
import org.nutz.dao.Cnd;
import org.nutz.dao.Condition;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.Map;

/**
 *
 */
@Transactional
@Path("goodsXiaoquService")
@Consumes({MediaType.APPLICATION_JSON, MediaType.TEXT_XML})
@Produces({ContentType.APPLICATION_JSON_UTF_8, ContentType.TEXT_XML_UTF_8})
public class GoodsXiaoquServiceImpl implements  GoodsXiaoquService{

    @Autowired
    private BaseDao dao;

    @POST
    @Path("find")
    @Transactional(readOnly = true)
    public MyPager find(Map params) {
        MyPager myPager = MyPagerUtils.myPager(params);
        Condition cnd = null;
        if (params != null && params.size() > 0) {

        }
        return dao.queryPager(GoodsXiaoqu.class, cnd, myPager);
    }

    @GET
    @Path("get/{id}")
    @Transactional(readOnly = true)
    public GoodsXiaoqu get(@PathParam("id")Long id) {
        return dao.fetch(GoodsXiaoqu.class, id);
    }

    @POST
    @Path("insert")
    public Responses insert(GoodsXiaoqu goodsXiaoqu) {
        dao.insert(goodsXiaoqu);
        return ResponseUtils.success();
    }

    @DELETE
    @Path("delete/{id}")
    public Responses delete(@PathParam("id")Long id) {
        dao.delete(GoodsXiaoqu.class, id);
        return ResponseUtils.success();
    }

    @Override
    public Responses update(GoodsXiaoqu goodsXiaoqu) {
        dao.updateIgnoreNull(goodsXiaoqu);
        return ResponseUtils.success();
    }

    @Override
    public Boolean isExistTemplate(Map map) {
        return null;
    }
}
